"""
阿里滑块
"""
from DrissionPage import ChromiumOptions, WebPage

base_url = 'http://purchase.ecrrc.com/order-0/list-0-0-0-1.html'


def crack_alhk():
    dp = ChromiumOptions()
    # dp.headless()  # 无头模式  过不了
    dp.set_argument('--headless')  # 无沙盒模式
    dp.set_argument('--no-sandbox')  # 无沙盒模式
    dp.set_argument('--disable-gpu')  # 禁用gpu加速
    dp.set_argument('--start-maximized')  # 设置启动时最大化
    dp.set_user_agent(
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36')
    page = WebPage(mode='d', chromium_options=dp)
    page.get(base_url)
    if '欢迎来到e车网' in page.html:
        return

    try:
        button = page.ele('@id=aliyunCaptcha-sliding-slider')
        page.actions.move_to(button).hold()
        page.actions.move(offset_x=320, offset_y=0, duration=0.5)
        page.actions.release()
        page.wait(2)
        print('破解结果: {}'.format('成功' if '欢迎来到e车网' in page.html else '失败'))
    finally:
        page.quit()


if __name__ == '__main__':
    crack_alhk()
